import user.ProxyUser;
import user.User;
import user.factory.AdimalFactory;
import user.factory.IUserFactory;
import user.factory.NormalFactory;

import java.util.Scanner;

public class LibrarySystem {
    public static void main(String[] args) {
        IUserFactory adimalUserFactory = new AdimalFactory();
        User adimal = adimalUserFactory.creatUser("zhangsan",1);
        IUserFactory normalUserFactory1 = new NormalFactory();
        User normal1 = normalUserFactory1.creatUser("lisi",14);
        User normal2 = normalUserFactory1.creatUser("wangwu",25);
        ProxyUser admialuser = new ProxyUser(adimal);
        ProxyUser normaluser1 = new ProxyUser(normal1);
        ProxyUser normaluser2 = new ProxyUser(normal2);
        LibrarySystem librarySystem = new LibrarySystem();
        ProxyUser currentUser = LibrarySystem.selectProxyPeople(admialuser,normaluser1,normaluser2);
        while(true){
            int choice = currentUser.dispaly();
            currentUser.handleOperation(choice);
        }


    }
    public static ProxyUser selectProxyPeople(ProxyUser proxyUserAdimal, ProxyUser proxyUserNormalw, ProxyUser proxyUserNormal){
        System.out.println("选择⻆⾊进⾏登录：");
        System.out.println("1.管理员\n2.普通⽤⼾(lisi)\n3.普通⽤⼾(wangwu)\n4.退出系统");
        ProxyUser currentUser = null;
        Scanner scanner = new Scanner(System.in);
        int choice = scanner.nextInt();

        switch (choice) {
            case 1:
                currentUser = proxyUserAdimal;
                break;
            case 2:
                currentUser = proxyUserNormalw;
                System.out.println();
                break;
            case 3:
                currentUser = proxyUserNormal;
                break;
            case 4:
                System.exit(0);
                System.out.println("系统已退出..");
                break;
            default:
                break;
        }
        return currentUser;
    }
}

